/* 基本样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-primary: #4f46e5;
  --color-primary-dark: #4338ca;
  --color-secondary: #7c3aed;
  --color-secondary-dark: #6d28d9;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #3b82f6;
  --color-text-primary: #1f2937;
  --color-text-secondary: #4b5563;
  --color-text-tertiary: #9ca3af;
  --color-text-light: #6b7280;
  --color-background: #ffffff;
  --color-background-alt: #f9fafb;
  --color-border: #e5e7eb;
  --color-surface: #ffffff;
  --color-surface-dark: #1f2937;
  --color-background-dark: #111827;
  --color-text-primary-dark: #f3f4f6;
  --color-text-secondary-dark: #9ca3af;
  --color-border-dark: #374151;
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --line-height-normal: 1.5;
  --line-height-dense: 1.25;
  --line-height-relaxed: 1.75;
  --apple-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  background-color: var(--color-background);
  color: var(--color-text-primary);
  /* Apple系统字体栈 */
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  /* 字体优化设置 */
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  /* Apple特有的字重设置 */
  font-weight: 400;
  line-height: 1.5;
}

#app {
  width: 100%;
  min-height: 100vh;
}

/* 全局文本标签样式 - 符合Apple设计规范 */
p {
  color: var(--color-text-primary);
  line-height: var(--line-height-normal);
}

[data-theme="dark"] p {
  color: var(--color-text-primary-dark, #ffffff);
}

span {
  color: inherit;
}

/* 确保所有标题和文本元素在深色模式下使用正确的颜色 */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-text-primary);
}

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6 {
  color: var(--color-text-primary-dark, #ffffff);
}

/* 确保链接在深色模式下有足够的对比度 */
a {
  color: var(--color-primary);
  text-decoration: none;
}

[data-theme="dark"] a {
  color: #ffffff;
}

/* 确保列表项文本颜色正确 */
ul, ol {
  color: var(--color-text-primary);
}

[data-theme="dark"] ul,
[data-theme="dark"] ol {
  color: var(--color-text-primary-dark, #ffffff);
}

li {
  color: inherit;
}

/* 确保标签元素文本颜色正确 */
label {
  color: var(--color-text-primary);
}

[data-theme="dark"] label {
  color: var(--color-text-primary-dark, #ffffff);
}

/* 确保表格文本颜色正确 */
table {
  color: var(--color-text-primary);
}

[data-theme="dark"] table {
  color: var(--color-text-primary-dark, #ffffff);
}

th, td {
  color: inherit;
}

/* 确保按钮文本颜色正确 */
button {
  color: var(--color-text-primary);
}

[data-theme="dark"] button {
  color: var(--color-text-primary-dark, #ffffff);
}

/* 确保输入框文本颜色正确 */
input, textarea, select {
  color: var(--color-text-primary);
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  color: var(--color-text-primary-dark, #ffffff);
}

/* 渐变文本处理 */
span[class*="bg-clip-text"] {
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
}

[data-theme="dark"] span[class*="bg-clip-text"] {
  background-image: linear-gradient(to right, #0066CC, #3B82F6) !important;
}

/* 响应式容器 */
.container {
  width: 100%;
  margin-right: auto;
  margin-left: auto;
  padding-right: 1rem;
  padding-left: 1rem;
}

/* 深色模式全局样式 */
[data-theme="dark"] {
  color-scheme: dark;
  color: var(--color-text-primary-dark, #ffffff);
  background-color: var(--color-background-dark, #111827);
}

/* 确保div元素在浅色模式下具有浅色背景，深色模式下具有深色背景 */
div {
  background-color: #f8f9fa; /* 浅色背景 */
}

[data-theme="dark"] div {
  background-color: var(--color-surface-dark, #1f2937);
}

/* 特殊div类别的背景色重置 */
[data-theme="dark"] .glass-effect,
[data-theme="dark"] .theme-switcher,
[data-theme="dark"] .app-container,
[data-theme="dark"] .app-header,
[data-theme="dark"] .app-main,
[data-theme="dark"] .app-footer,
[data-theme="dark"] .demo-grid,
[data-theme="dark"] .demo-content,
[data-theme="dark"] .api-group,
[data-theme="dark"] .value-display,
[data-theme="dark"] .user-info {
  background-color: transparent;
}

/* 确保所有元素在深色模式下继承正确的文本颜色 */
[data-theme="dark"] * {
  color: inherit;
}

/* 重置特定元素的颜色，确保自定义颜色仍能正常工作 */
[data-theme="dark"] .bg-clip-text,
[data-theme="dark"] span[class*="bg-clip-text"],
[data-theme="dark"] button:not(.bg-clip-text),
[data-theme="dark"] a:not(.bg-clip-text),
[data-theme="dark"] .category-badge {
  color: inherit;
}

@media (min-width: 640px) {
  .container {
    max-width: 640px;
  }
}

@media (min-width: 768px) {
  .container {
    max-width: 768px;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 1024px;
  }
}

@media (min-width: 1280px) {
  .container {
    max-width: 1280px;
  }
}

/* 深色模式样式 */
[data-theme="dark"] body {
  background-color: var(--color-background-dark);
  color: var(--color-text-primary-dark);
}

/* 卡片样式 */
.card {
  background-color: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  transition: var(--apple-transition);
}

[data-theme="dark"] .card {
  background-color: var(--color-surface-dark);
  box-shadow: var(--shadow-lg);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

[data-theme="dark"] .card:hover {
  box-shadow: var(--shadow-xl);
}

/* 按钮样式 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  cursor: pointer;
  transition: var(--apple-transition);
  border: none;
  outline: none;
}

.btn-primary {
  background-color: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--color-primary-dark);
}

.btn-secondary {
  background-color: var(--color-secondary);
  color: white;
}

.btn-secondary:hover {
  background-color: var(--color-secondary-dark);
}

/* 响应式布局辅助类 */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-4 {
  gap: 1rem;
}

.gap-8 {
  gap: 2rem;
}

/* 间距工具类 */
.m-1 { margin: 0.25rem; }
.m-2 { margin: 0.5rem; }
.m-4 { margin: 1rem; }
.m-8 { margin: 2rem; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-4 { padding: 1rem; }
.p-8 { padding: 2rem; }

/* 文本样式工具类 */
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }

/* 隐藏元素 */
.hidden {
  display: none;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--color-text-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-text-secondary);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background-color: var(--color-text-secondary-dark);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-text-primary-dark);
}

/* 动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease-out;
}

.slide-in {
  animation: slideIn 0.3s ease-out;
}

/* 过渡效果 */
.transition-all {
  transition: all 0.2s ease;
}

.transition-transform {
  transition: transform 0.2s ease;
}

.transition-opacity {
  transition: opacity 0.2s ease;
}